﻿using USClientKernel.MVC;
using Game.Logic.Manager;
using Game.Logic.Data;

namespace Game.Kernel
{
    public class GameBaseModelEvent : ModelEvent<GameBaseData>
    {
      
    }

    public abstract class GameBaseModel : BaseModel<GameBaseData, GameBaseModelEvent>
    {
        #region Data Event Handler
        public virtual GameBaseData GetGameData(GameDataType _dataType)
        {
            return GameDataManager.Instance.GetGameData(_dataType);
        }

        public virtual T GetGameData<T>(GameDataType _dataType) where T : GameBaseData
        {
            return GameDataManager.Instance.GetGameData(_dataType) as T;
        }

        public virtual T RegisterDataEventHandler<T>(GameDataType _dataType, OnDataEventHandler<GameBaseData> _handler) where T : GameBaseData
        {
            T ret = GetGameData(_dataType) as T;
            ret.RegisterDataEventHandler(_handler);
            return ret;
        }

        public virtual void UnregisterDataEventHandler<T>(T _data, OnDataEventHandler<GameBaseData> _handler) where T : GameBaseData
        {
            _data.UnregisterDataEventHandler(_handler);
        }
        #endregion


        #region Model Event
        public override void DispatchModelEvent(GameBaseModelEvent me)
        {
            base.DispatchModelEvent(me);
        }
        #endregion


        #region Model And View Interaction
        protected override void OnLinkView()
        {

        }

        protected override void OnUnlinkView()
        {

        }
        #endregion

    }
}
